<template>
    <div>
        手机号<input type="text" v-model="mobile">
        <button @click="add">提交</button>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                type:this.$route.query.type,
                uid:0,
                mobile:'',
                token:''
            }
        },
        methods: {
            //提交
            add(){
                this.$axios.post('/users/bindmobile/',{'uid':this.uid,'token':this.token,'mobile':this.mobile}).then(res=>{
                    localStorage.setItem('id',res.data.id)
                    localStorage.setItem('name',res.data.name)
                    this.$router.push('/')
                })
            }
        },
        mounted() {
             //type=1代表已授权直接跳转并且保存id和名称
                if(this.type == 1){
                    let id=this.$route.query.id
                    let name=this.$route.query.name
                    localStorage.setItem('id',id)
                    localStorage.setItem('name',name)
                    this.$router.push('/')
                }else{
                    let uid=this.$route.query.uid
                    this.uid = uid
                    let token=this.$route.query.token
                    this.token = token
                }
        },
    }
</script>

<style scoped>

</style>